<?php

/* Usage:
 * createSelect($infos, $count);
* creates a Radio select for the specific info_struct at the place where the functin is called
* paramter:
* $infos - info_struct with the specific infos for the radio select
* $count - 0 gives a prechecked radio - all others are for the decision which radio button is selected and which infos should be used
* return:
* -
* remark:
* html code will be displayed where this function is called
*/

function createSelect($infos, $count = 0) {

    /*
     * Create text string for description with the link to the article
    */
    $info_string = $infos->title." (".$infos->year.") by ".$infos->author;

    switch ($infos->from)
    {
        case "arx":
            $prefix_type = "arx";
            $info_string = "<a class=\"validate_a\" target=\"_blank\" href=\"http://arxiv.org/abs/$infos->arxiv\">$info_string</a>";
            break;
        case "doi":
            $prefix_type = "doi";
            $info_string = "<a class=\"validate_a\" target=\"_blank\" href=\"http://dx.doi.org/$infos->doi\">$info_string</a>";
            break;
        case "zma":
            $prefix_type = "zma";
            $info_string = "<a class=\"validate_a\" target=\"_blank\" href=\"https://zbmath.org/?q=an:$infos->zmath\">$info_string</a>";
            break;
            	
        case "ldb":
            $prefix_type = "man";
            $info_string = "<span style='color: black; margin: 0px; padding: 0px;'>$info_string</span>";//<br>Entry in our database.
            break;
            	
        case "arx_blank":
            $prefix_type = "arx";
            $info_string = "Neither of the above ArXiv articles match.";
            break;
        case "doi_blank":
            $prefix_type = "doi";
            $info_string = "Neither of the above DOI articles match.";
            break;
        case "zma_blank":
            $prefix_type = "zma";
            $info_string = "Neither of the above ZMath articles match.";
            break;
            	
        case "ldb_blank":
            $prefix_type = "man";
            $info_string = "The entry in our database doesn't match.";
            break;

        default:
            $prefix_type = "man";
    }

    if ($count === 0) {
        ?>
<label class="radio radio-custom checkbox checked"> <input type="radio"
	name="radio<?=$prefix_type?>" value="<?=$prefix_type?><?=$count?>"
	checked> <i class="radio"></i> <?php
    } else {
?> <label class="radio radio-custom checkbox"> <input type="radio"
		name="radio<?=$prefix_type?>" value="<?=$prefix_type?><?=$count?>"> <i
		class="radio"></i> <?php
        }
        echo $info_string;
        ?> <input type="hidden"
		name="serial<?=$prefix_type?><?=$count?>"
		value='<?=base64_encode(serialize($infos));?>'>
</label> <?php
}

/*
 * Usage:
* from_to_db_name($in);
* resolves info_struct->from to database name
* parameter:
* $in - string with data from info_struct->from
* return:
* string with the resolved name
 */

function from_to_db_name($in) {
	switch ($in) 
	{
		case "zma":
			return "ZMath";
		case "arx":
			return "ArXiv";
		case "doi":
			return "DOI";
		case "ldb":
			return "Local Database";
		case "man":
			return "Manual Input";
		default:
			return "";
	}
}
?>